<?php
class BkasController extends AppController {

	var $name = 'Bkas';
	var $helpers = array('Html', 'Form');
    var $paginate = array('limit' => 10, 'page' => 1, 'order' =>array('Bka.date_bk'=>'desc'));
 

	function index() {
		$this->Bka->recursive = 0;
		$this->set('bkas', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Bka.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('bka', $this->Bka->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Bka->create();
			if ($this->Bka->save($this->data)) {
				$this->Session->setFlash(__('The Bka has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Bka could not be saved. Please, try again.', true));
			}
		}
		$canbos = $this->Bka->Canbo->find('list');
		$this->set(compact('canbos'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Bka', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Bka->save($this->data)) {
				$this->Session->setFlash(__('The Bka has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Bka could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Bka->read(null, $id);
		}
		$canbos = $this->Bka->Canbo->find('list');
		$this->set(compact('canbos'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Bka', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Bka->del($id)) {
			$this->Session->setFlash(__('Bka deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>